package com.rc.saas.tenant.service.enterprise;

import com.rc.saas.tenant.mapper.enterprise.RcEnterpriseGainGradeRecordMapper;
import com.rc.saas.tenant.model.enterprise.RcEnterpriseGainGradeRecord;
import com.rc.saas.tenant.model.enterprise.RcEnterpriseGainGradeRecordExample;
import com.rc.saas.tenant.model.enterprise.RcEnterpriseGainRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RcEnterpriseGainGradeRecordServiceImpl implements RcEnterpriseGainGradeRecordService{

    @Autowired
    private RcEnterpriseGainGradeRecordMapper enterpriseGainGradeRecordMapper;

    @Override
    public RcEnterpriseGainGradeRecordMapper getMapper() {
        return enterpriseGainGradeRecordMapper;
    }

    @Override
    public RcEnterpriseGainGradeRecord selectGainGradeRecordByEnterpriseId(Long enterpriseId) {
        return enterpriseGainGradeRecordMapper.selectGainGradeRecordByEnterpriseId(enterpriseId);
    }

    @Override
    public void deleteGradeRecordByEnterpriseId(Long enterpriseId) {
        RcEnterpriseGainGradeRecordExample example = new RcEnterpriseGainGradeRecordExample();
        example.createCriteria().andEnterpriseGainIdEqualTo(enterpriseId);
        enterpriseGainGradeRecordMapper.deleteByExample(example);
        List<RcEnterpriseGainGradeRecord> list = enterpriseGainGradeRecordMapper.selectByExample(example);
        for (RcEnterpriseGainGradeRecord record : list) {
            enterpriseGainGradeRecordMapper.deleteByPrimaryKey(record.getEnterpriseGainGradeRecordId());
        }
    }
}
